package pattern10.boss;

import java.util.ArrayList;
import java.util.List;

/**
 * 前台秘书
 *
 * @author wdl
 */
public class Secretary implements ISubject{
    /**
     * 同事列表
     */
    private List<BaseObserver> observers = new ArrayList<>();
    private String action;

    /**
     * 增加
     * @param observer 同事
     */
    @Override
    public void Attach(BaseObserver observer) {
        observers.add(observer);
    }

    @Override
    public void Detach(BaseObserver observer) {
        observers.remove(observer);
    }

    /**
     * 通知同事
     */
    @Override
    public void Notify(){
        for (BaseObserver observer:observers){
            observer.update();
        }
    }

    @Override
    public String getAction() {
        return action;
    }

    @Override
    public void setAction(String action) {
        this.action=action;
    }
}
